package com.foo.actions;

import javax.servlet.http.*;
import org.apache.struts.action.*;
import com.foo.forms.TestForm;

public final class TestAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form, 
			HttpServletRequest request, HttpServletResponse response) throws Exception {

        ActionErrors errors = new ActionErrors();
        TestForm testForm = (TestForm) form;
        String name = testForm.getFirstname();
        request.setAttribute("test", form);
        // Dummy business logic: here is where you would typically communicate with a business object
        if (name != null && name.length() < 3) {        	
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.minlength", "First Name", 3));
            saveErrors(request,errors);
            return mapping.findForward(mapping.getForward());
        }

       
        return mapping.findForward(mapping.getForward());        
    }

 }
